package cn.com.open.errorquestion.controller;

import cn.com.open.errorquestion.common.Result;
import cn.com.open.errorquestion.common.ResultGenerator;
import cn.com.open.errorquestion.model.AnswerQuestionLog;
import cn.com.open.errorquestion.service.AnswerQuestionLogService;
import cn.com.open.errorquestion.util.StringUtil;
import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/answerquestionlog")
public class AnswerQuestionLogController {

    private static Logger logger = LoggerFactory.getLogger(AnswerQuestionLogController.class);


    @Autowired
    private AnswerQuestionLogService answerQuestionLogService;

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    public String saveAnswerQuestionLog(@RequestBody List<AnswerQuestionLog> answerDatas){
//        logger.info("保存试题作答记录");

        try {
//            for ( AnswerQuestionLog answerData: answerDatas) {
//                answerQuestionLogService.saveQuestion(answerData);
//            }
                answerQuestionLogService.saveQuestion(answerDatas);
        } catch (Exception e) {
            e.printStackTrace();
        }
//        answerQuestionLogService.save(answerData);
        return JSON.toJSONString(ResultGenerator.genSuccessResult());
    }
}
